﻿using System;
using System.Collections.Generic;
using System.Linq;

using Microsoft.Xna.Framework.Input;


namespace WorldOnFire
{
    class CMenuPauseCampaign : ABCMenu
    {
        private enum eOptions
        {
            RESUME,
            RESTART,
            SAVE,
            LOAD,
            OPTIONS_,
            EXIT_,
            COUNT
        };

        private enum eExpandableOptions
        {
            OPTIONS,
            EXIT,
            COUNT
        };

        private enum eOptionsOptions
        {
            CONTROLS,
            VIDEO,
            AUDIO,
            COUNT
        };

        private enum eExitOptions
        {
            CAMPAIGN_LOBBY,
            MAIN_MENU,
            DESKTOP,
            COUNT
        }

        public override void Initialize()
        {
            // Initialize the options
            m_nOptionCount = (int)eOptions.COUNT;
            m_strOptionTitles = new string[(int)eOptions.COUNT] 
            {
                "Resume",
                "Restart",
                "Save Game",
                "Load Game",
                "Options",
                "Exit"
            };

            // Initialize the expandable options
            m_nExpandableOptionCount = (int)eExpandableOptions.COUNT;
            m_ExpandableOptions = new tExpandableOption[(int)eExpandableOptions.COUNT];
            m_nExpandableOptionIndices = new int[(int)eExpandableOptions.COUNT]
            {
                (int)eOptions.OPTIONS_,
                (int)eOptions.EXIT_
            };

            // Set the data for each expandable option
            m_ExpandableOptions[(int)eExpandableOptions.OPTIONS].nOptionCount = (int)eOptionsOptions.COUNT;
            m_ExpandableOptions[(int)eExpandableOptions.OPTIONS].strOptionTitles = new string[(int)eOptionsOptions.COUNT]
            {
                "Controls",
                "Video",
                "Audio"
            };

            m_ExpandableOptions[(int)eExpandableOptions.EXIT].nOptionCount = (int)eExitOptions.COUNT;
            m_ExpandableOptions[(int)eExpandableOptions.EXIT].strOptionTitles = new string[(int)eExitOptions.COUNT]
            {
                "Campaign Lobby",
                "Main Menu",
                "Exit to Desktop"
            };

            base.Initialize();
        }

        public override void Input(float _fDeltaTime)
        {
            // TODO: FUCKING INPUT. JESUS CHRIST.

            if (SInputManager.IsKeyPressed(Keys.Enter) == true)
            {
                switch (m_nSelectedIndex)
                {
                    case (int)eOptions.RESUME:
                        {

                        }
                        break;
                    case (int)eOptions.RESTART:
                        {

                        }
                        break;
                    case (int)eOptions.SAVE:
                        {

                        }
                        break;
                    case (int)eOptions.LOAD:
                        {

                        }
                        break;
                    case (int)eOptions.OPTIONS_:
                        {
                            // If the selection is expanded,
                            if (m_bSelectionExpanded == true)
                            {
                                // The expanded option handles input
                                switch (m_ExpandableOptions[(int)eExpandableOptions.OPTIONS].nSelectedIndex)
                                {
                                    case (int)eOptionsOptions.CONTROLS:
                                        {

                                        }
                                        break;
                                    case (int)eOptionsOptions.VIDEO:
                                        {
                                            s_StateManager.Push(new CMenuOptionsVideo());
                                        }
                                        return;
                                    case (int)eOptionsOptions.AUDIO:
                                        {
                                            s_StateManager.Push(new CMenuOptionsAudio());
                                        }
                                        return;
                                }
                            }
                            // If the selection is not expanded
                            else
                            {
                                // Expand it
                                m_bSelectionExpanded = true;
                            }
                        }
                        break;
                    case (int)eOptions.EXIT_:
                        {
                            // If the selection is expanded,
                            if (m_bSelectionExpanded == true)
                            {
                                // The expanded option handles input
                                switch (m_ExpandableOptions[(int)eExpandableOptions.EXIT].nSelectedIndex)
                                {
                                    case (int)eExitOptions.CAMPAIGN_LOBBY:
                                        {

                                        }
                                        break;
                                    case (int)eExitOptions.MAIN_MENU:
                                        {
                                            s_StateManager.Switch(new CMenuMain());
                                        }
                                        return;
                                    case (int)eExitOptions.DESKTOP:
                                        {
                                            s_Game.Exit();
                                        }
                                        return;
                                }
                            }
                            // If the selection is not expanded
                            else
                            {
                                // Expand it
                                m_bSelectionExpanded = true;
                            }
                        }
                        break;
                }
            }

            base.Input(_fDeltaTime);
        }
    }
}
